<template>
  <div class="GouMai-Page">
    <div class="alert alert-success" v-if="date" style="width:100%;margin: auto">{{date}}<span class="close" @click="date=''">&times;</span></div>
    <div v-for="item in items">
      <img :src="item.picture" style="width: 100%;height: 250px;"/>
      <div>品牌:{{item.shopname}}</div>
      <div>今日优惠价:{{item.price}}</div>
      <div>商家:本商品为限购商品,每位客户仅能购买一次</div>
      <el-button @click="Mai()" type="success" ><router-link :to="{path:'/goumai/'+item.id}">加入购物车</router-link></el-button>
      <el-button @click="MaiMai()" type="success" >立即购买</el-button>
    </div>
  </div>
</template>
<script>
  export default {
    name: 'GouMai-Page',
    data() {
      return {
        items:{},
        date:''
      }
    },
    computed:{
    },
    mounted() {
      this.$http.get('/goumai/'+this.$route.params.id).then(resp=>{
//        console.log(localStorage.id);
        console.log(resp.data);
        this.items = resp.data;
//        this.items = resp.data;
//            for(let sp of resp.data[1]){
//               this.shops = sp.picture;
//            }
      }).catch(err=>console.log(err));
    },
    methods: {
      Mai(){
        this.$http.get('/tejia/'+this.$route.params.id)
          .then(resp => {
    //console.log(b.shop.id);
            this.date = resp.data;
//    this.$route.params.id = 7;
          })
      },
    }
  }
</script>
<style lang="less">
  .GouMai-Page {
    width: 100%;height: 100%;
    overflow-x: hidden;overflow-y: hidden;
  }

</style>
